import os
from typing import Optional, Dict, Any
from pydantic_settings import BaseSettings
from dotenv import load_dotenv

# 加载环境变量
load_dotenv()

class Settings(BaseSettings):
    """应用程序配置设置"""
    # 应用程序信息
    APP_NAME: str = "商家评分决策AI服务"
    APP_DESCRIPTION: str = "提供商家各指标评分和决策的AI服务"
    APP_VERSION: str = "1.0.0"
    API_V1_STR: str = "/api"
    # CORS配置
    CORS_ORIGINS: list = ["*"]  # 不限制访问
    
    # AI模型配置
    OPENROUTER_KEY: Optional[str] = os.getenv("OPENROUTER_KEY")
    print('OPENROUTER_KEY',OPENROUTER_KEY)
    DEFAULT_MODEL: str = "google/gemini-2.0-flash-001"
    
    # 日志配置
    LOG_LEVEL: str = os.getenv("LOG_LEVEL", "INFO")
    
    # 其他配置
    DEBUG: bool = os.getenv("DEBUG", "False").lower() in ("true", "1", "t")

    class Config:
        env_file = ".env"
        case_sensitive = True


# 创建全局设置实例
settings = Settings()

# 模型配置
model_settings = {
    "evaluation": {
        "model": settings.DEFAULT_MODEL,
        "temperature": 0.2,
        "max_tokens": 4000
    },
    "decision": {
        "model": settings.DEFAULT_MODEL,
        "temperature": 0.1,
        "max_tokens": 2000
    }
} 